<%@ page import="com.situ.web.pojo.Student" %>
<%@ page import="java.util.List" %>
<%@ page import="com.situ.web.pojo.vo.StudentBanjiVO" %><%--
  Created by IntelliJ IDEA.
  User: Gao
  Date: 2023/7/26
  Time: 11:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="static/bootstrap-3.4.1-dist/css/bootstrap.css">
</head>
<body>
    <%
        //JSP页面中可以嵌套Java代码
        //JSP脚本：在这里可以写任意的Java代码
        //request、response:JSP页面的内置对象
        List<StudentBanjiVO> list = (List<StudentBanjiVO>) request.getAttribute("list");
    %>
    <a class="btn btn-primary" href="<%=request.getContextPath()%>/student_add.jsp">添加</a>
    <table class="table table-striped table-bordered table-hover table-condensed">
        <tr>
            <td>ID</td>
            <td>名字</td>
            <td>年龄</td>
            <td>性别</td>
            <td>班级名</td>
            <td>地址</td>
            <td>编辑</td>
            <td>删除</td>
        </tr>
        <%
            for (StudentBanjiVO studentBanjiVO : list) {
        %>
                 <tr>
                    <td><%=studentBanjiVO.getId()%></td>
                    <td><%=studentBanjiVO.getName()%></td>
                    <td><%=studentBanjiVO.getAge()%></td>
                    <td><%=studentBanjiVO.getGender()%></td>
                    <td><%=studentBanjiVO.getBanjiName()%></td>
                    <td><%=studentBanjiVO.getAddress()%></td>
                     <td><a href="<%=request.getContextPath()%>/student?method=getStudentUpdatePage&id=<%=studentBanjiVO.getId()%>">编辑</a></td>
                     <%--/JavaWeb/deleteStudent?id=12 --%>
                    <%--<td><a href="<%=request.getContextPath()%>/deleteStudent?id=<%=student.getId()%>">删除</a></td>--%>
                    <%--<td><a href="<%=request.getContextPath()%>/student?method=deleteById&id=<%=student.getId()%>">删除</a></td>--%>
                    <td><a href="javascript:deleteById(<%=studentBanjiVO.getId()%>)">删除</a></td>
                </tr>
        <%
            }
        %>


    </table>
    <nav aria-label="Page navigation">
        <ul class="pagination">
            <li>
                <a href="#" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            <li><a href="#">1</a></li>
            <li><a href="#">2</a></li>
            <li><a href="#">3</a></li>
            <li><a href="#">4</a></li>
            <li><a href="#">5</a></li>
            <li>
                <a href="#" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
        </ul>
    </nav>

    <script>
        function deleteById(id) {
            var isDelete = confirm('您确认要删除？');
            if (isDelete) {
               location.href = '<%=request.getContextPath()%>/student?method=deleteById&id=' + id;
            }
        }
    </script>
</body>
</html>
